<?php

namespace App\Http\Controllers\Admin;

use App\Exports\FztPaymentOrderStatusExport;
use App\Exports\RestoreOrdersExport;
use App\Http\Controllers\Controller;
use App\Mail\AgentSelfEmployedExportMail;
use Illuminate\Http\Request;
use Illuminate\Mail\Message;
use Illuminate\Support\Facades\Mail;

class DevController extends Controller
{
    /**
     * 获取重新下单的结果 excel
     * @param Request $request
     * @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\BinaryFileResponse
     */
    public function exportRestoreOrders(Request $request)
    {
        return (new RestoreOrdersExport($request->get('batch_number'), $request->get('type', 'successful')))
            ->download('重新下单批次号:' . $request->get('batch_number') . '.xls');
    }

    public function exportFztPaymentOrderStatus(Request $request)
    {
        return (new FztPaymentOrderStatusExport($request->get('batch_number')))
            ->download('充值订单状态:' . $request->get('batch_number') . '.xls');
    }

    /**
     * 清理活动缓存
     * @return \Dingo\Api\Http\Response
     */
    public function cleanCacheActivities()
    {
        \App\Services\Commodity::forgetCommodityActivityListCacheTag(); // 清除缓存

        return $this->response->noContent();
    }

    /**
     * 发送邮件
     */
    public function sendEmail()
    {
        Mail::to('nepab6vr@linshiyouxiang.net')
            ->send(
                (new AgentSelfEmployedExportMail())
                    ->subject('测试')
                    ->attachFromStorageDisk('oss', '/代理商(20201119011427334370).xls')
            );
    }
}
